package cn.hxzy.company.controller;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author little black
 */
@ResponseBody
@ControllerAdvice
public class MyControllerAdvice {

    @ExceptionHandler
    public Map exceptionHandler(Exception ex){
        ex.printStackTrace();
        ex.printStackTrace();
        Map map=new HashMap();
        map.put("exception", ex.getMessage());
        System.out.println("in testExceptionHandler");
        return map;
    }

}